package cn.jiyun.springcloud_feign_consumer.controller;

import cn.jiyun.User;
import cn.jiyun.springcloud_feign_consumer.feign.UserFeign;
import cn.jiyun.springcloud_feign_consumer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    UserFeign userFeign;

    @Autowired
    UserService userService;

    @RequestMapping("consumer/{id}")
    public User getUser(@PathVariable Integer id){

        // restTemplate，麻烦
        // feign替代
        userService.getUser(1);
        return userFeign.getUser(id);
    }

}
